export default (data: { titleArr: []; itemArr: [] }) => {
  const { titleArr, itemArr } = data;
  let str = `${titleArr.join(',')}\n`;

  itemArr.forEach((item) => {
    str += `${Object.values(item).join('\t,')}\n`;
  });

  // encodeURIComponent解决中文乱码
  const uri = `data:text/xls;charset=utf-8,\ufeff${encodeURIComponent(str)}`;
  const link = document.createElement('a');
  link.href = uri;
  link.download = `${Date.now()}.xls`;
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
};
